﻿@extends('layouts.shop_main')

@section('title', '首页')

@section('resources')
    @parent
    <style>
        .index_timer{overflow: hidden;margin: 15px 40px;}
        .index_timer li{float: left;margin-left: 10px;font-size: 16px;}
        .main-stats .title{margin: 20px 50px;font-size: 16px;border-left: 3px solid #9955c6;padding-left: 20px;}
        .main-stats .isdouble{margin: 20px 50px;font-size: 16px;padding-left: 23px;}
        .spread{margin: 10px 50px;font-size: 16px;color: #9955c6;cursor: pointer;overflow: hidden;}
        .spread span{float: left;margin-right: 10px;}
        .spread img{float: left;margin: 3px 0;}
        .statsChart{text-align: center;background: rgba(0,0,0,0.15);color: #fff;font-size: 18px;width: 250px;height: 50px;line-height: 50px;border-radius: 5px;margin: 50px auto;}
    </style>
@endsection

@section('content')
	<!-- main container -->
    <div class="content">
        <ul class="index_timer">
            <li>{{date('Y-m-d')}}</li>
            @if(date('w') == 1)
            <li>星期一</li>
            @elseif(date('w') == 2)
            <li>星期二</li>
            @elseif(date('w') == 3)
            <li>星期三</li>
            @elseif(date('w') == 4)
            <li>星期四</li>
            @elseif(date('w') == 5)
            <li>星期五</li>
            @elseif(date('w') == 6)
            <li>星期六</li>
            @elseif(date('w') == 7)
            <li>星期天</li>
            @endif
            {{--<li>妇女节</li>--}}
        </ul>
        <div class="main-stats">
            <div class="row stats-row">
                <div class="col-md-3 col-sm-3 stat">
                    <div class="data">
                    @if($todayordercount == 0 || $todayordercount == '')
                        <span class="number">--</span>
                    @else
                        <span class="number">{{$todayordercount}}</span>
                    @endif
                    </div>
                    <span class="date">今天订单数</span>
                </div>
                <div class="col-md-3 col-sm-3 stat">
                    <div class="data">
                    @if($todayordersum == 0 || $todayordersum == '')
                        <span class="number">--</span>
                    @else
                        <span class="number">{{$todayordersum}}</span>
                    @endif
                    </div>
                    <span class="date">今日订单消费金额</span>
                </div>
                <div class="col-md-3 col-sm-3 stat">
                    <div class="data">
                    @if($todaysalesmancount == 0 || $todaysalesmancount == '')
                        <span class="number">--</span>
                    @else
                        <span class="number">{{$todaysalesmancount}}</span>
                    @endif
                    </div>
                    <span class="date">今日地推注册数</span>
                </div>
                <div class="col-md-3 col-sm-3 stat last">
                    <div class="data">
                        @if($todaysalesmansum == 0 || $todaysalesmansum == '')
                            <span class="number">--</span>
                        @else
                            <span class="number">¥ {{$todaysalesmansum}}</span>
                        @endif
                    </div>
                    <span class="date">今日地推收入(元)</span>
                </div>
            </div>
        </div>
        <!-- 多门店展示 -->
        <ul>
            @foreach($lists as $list)
            <li class="main-stats">
                <input class="shopids" type="hidden" name="" value="{{$list['shopid']}}">
                <p class="title">{{$list['name']}}</p>
                @if($list['todayevent'])
                    <p  class="isdouble">今天是翻倍日</p>
                @else
                    @if($list['nextevent'] != '0000-00-00')
                        <p  class="isdouble">今天不是翻倍日，最近翻倍日是{{date('Y-m-d', strtotime($list['nextevent']))}}</p>
                    @else
                        <p  class="isdouble">今天不是翻倍日，最近无翻倍日</p>
                    @endif
                @endif
                <div class="row stats-row">
                    <div class="row stats-row">
                        <div class="col-md-3 col-sm-3 stat">
                            <div class="data">
                                <span class="number">{{$list['todayordercount']}}</span>
                            </div>
                            <span class="date">今天订单数</span>
                        </div>
                        <div class="col-md-3 col-sm-3 stat">
                            <div class="data">
                            @if($list['todayordersum'] == 0 || $list['todayordersum'] == '')
                                <span class="number">--</span>
                            @else
                                <span class="number">{{$list['todayordersum']}}</span>
                            @endif
                            </div>
                            <span class="date">今日订单消费金额</span>
                        </div>
                        <div class="col-md-3 col-sm-3 stat">
                            <div class="data">
                                <span class="number">{{$list['todaysalesmancount']}}</span>
                            </div>
                            <span class="date">今日地推注册数</span>
                        </div>
                        <div class="col-md-3 col-sm-3 stat last">
                            <div class="data">
                            @if($list['todaysalesmansum'] == 0 || $list['todaysalesman'] == '')
                                 <span class="number">--</span>
                            @else
                                <span class="number">¥ {{$list['todaysalesmansum']}}</span>
                            @endif
                            </div>
                            <span class="date">今日地推收入(元)</span>
                        </div>
                    </div>
                </div>
                <div class="pad-wrapper" style="padding: 0 40px;">
                    <div class="row chart">
                        <p  class="spread">
                            <span>最近7个翻倍日订单数变化</span>
                            <img src="{{env('IMAGE_DOMAIN')}}images/shop/bgs/down.png" alt="">
                        </p>
                        <div class="col-md-12">
                            
                        </div>
                    </div>
                </div>
            </li>
            @endforeach
            {{--<li class="main-stats">--}}
                {{--<p class="title">罗纳咖啡(新建中心店)</p>--}}
                {{--<p  class="isdouble">今天是翻倍日</p>--}}
                {{--<div class="row stats-row">--}}
                    {{--<div class="row stats-row">--}}
                        {{--<div class="col-md-3 col-sm-3 stat">--}}
                            {{--<div class="data">--}}
                                {{--<span class="number">2457</span>--}}
                            {{--</div>--}}
                            {{--<span class="date">今天订单数</span>--}}
                        {{--</div>--}}
                        {{--<div class="col-md-3 col-sm-3 stat">--}}
                            {{--<div class="data">--}}
                                {{--<span class="number">3240</span>--}}
                            {{--</div>--}}
                            {{--<span class="date">今日订单消费金额</span>--}}
                        {{--</div>--}}
                        {{--<div class="col-md-3 col-sm-3 stat">--}}
                            {{--<div class="data">--}}
                                {{--<span class="number">322</span>--}}
                            {{--</div>--}}
                            {{--<span class="date">今日地推注册数</span>--}}
                        {{--</div>--}}
                        {{--<div class="col-md-3 col-sm-3 stat last">--}}
                            {{--<div class="data">--}}
                                {{--<span class="number">$2,340</span>--}}
                            {{--</div>--}}
                            {{--<span class="date">今日地推收入(元)</span>--}}
                        {{--</div>--}}
                    {{--</div>--}}
                {{--</div>--}}
                {{--<div class="pad-wrapper" style="padding: 0 50px;">--}}
                    {{--<div class="row chart">--}}
                        {{--<p  class="spread">最近7个翻倍日订单数变化</p>--}}
                        {{--<div class="col-md-12">--}}
                            {{--<div id="statsChart"></div>--}}
                        {{--</div>--}}
                    {{--</div>--}}
                {{--</div>--}}
            {{--</li>--}}
        </ul>
    </div>
@endsection

@section('scriptResources')
    @parent
    <script>

        // jQuery Flot Chart
            $(".spread").click(function(){
                for (var i = 0; i < $(".col-md-12").length; i++) {
                    $(".col-md-12").eq(i).empty()
                };
                $(this).siblings('.col-md-12').html('<div id="statsChart"></div>');
                var shopid = $(this).parent().parent().siblings(".shopids").val();
                chart(shopid);
            })
            function chart(shopid){
                var orders = [];
                var ticks = [];
                $.ajax({
                    url :"/shop/order/event/chart",
                    type:'get',
                    data : {
                        shopid:shopid
                    },
                    dataType:'json',
                    async:true,
                    success:function(data){
                        if (data.status == "success") {
                            var data = data.data;
                            orders = data['ylabel'];
                            ticks = data['xlabel'];
                            var isshow = data['isshow'];
                            if(isshow == 1){
                                var plot = $.plot($("#statsChart"),
                                    [
                                        { data: orders, label: "订单数"}
                                    ],
                                    {
                                        series: {
                                            lines: { show: true,
                                                    lineWidth: 1,
                                                    fill: true,
                                                    fillColor: { colors: [ { opacity: 0.1 }, { opacity: 0.13 } ] }
                                                 },
                                            points: { show: true,
                                                     lineWidth: 2,
                                                     radius: 3
                                                 },
                                            shadowSize: 0,
                                            stack: true
                                        },
                                        grid: { hoverable: true,
                                               clickable: true,
                                               tickColor: "#f9f9f9",
                                               borderWidth: 0
                                            },
                                        legend: {
                                                // show: false
                                                labelBoxBorderColor: "#fff"
                                            },
                                        colors: ["#a7b5c5",  "#30a0eb"],
                                        xaxis: {
                                            ticks: ticks,
                                            font: {
                                                size: 12,
                                                family: "Open Sans, Arial",
                                                variant: "small-caps",
                                                color: "#697695"
                                            }
                                        },
                                        yaxis: {
                                            ticks:3,
                                            tickDecimals: 0,
                                            font: {size:12, color: "#9da3a9"}
                                        }
                                    });
                            }else{
                                $("#statsChart").html("暂无数据");
                                $("#statsChart").addClass('statsChart');
                                $("#statsChart").css({"height":"50px","margin-top":"50px"});
                            }
                        } else {
                            //alert(data.message);
                        }
                    }
                });
            }
    </script>
@endsection